package org.example;

import javax.swing.*;
import java.awt.*;

public class HiLoFrame extends JFrame {

    private Container contentP;
    private UpPanel upP;
    private MidPanel midP;
    private DownPanel downP;
    private int randomNum;

    public HiLoFrame() {
        this.randomNum = (int) (Math.random() * 50 + 50);//50-99之间的随机数

        this.setSize(300, 327);
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        this.setTitle("高低数游戏");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.addContent();
        this.setVisible(true);
    }

    private void addContent() {
        this.contentP = this.getContentPane();
        this.contentP.setLayout(new GridLayout(3, 1));

        this.upP = new UpPanel();
        this.midP = new MidPanel();
        this.downP = new DownPanel(this, upP, midP);

        this.contentP.add(this.upP);
        this.contentP.add(this.midP);
        this.contentP.add(this.downP);
    }

    public Container getContentP() {
        return contentP;
    }

    public void setContentP(Container contentP) {
        this.contentP = contentP;
    }

    public UpPanel getUpP() {
        return upP;
    }

    public void setUpP(UpPanel upP) {
        this.upP = upP;
    }

    public MidPanel getMidP() {
        return midP;
    }

    public void setMidP(MidPanel midP) {
        this.midP = midP;
    }

    public DownPanel getDownP() {
        return downP;
    }

    public void setDownP(DownPanel downP) {
        this.downP = downP;
    }

    public int getRandomNum() {
        return randomNum;
    }

    public void setRandomNum(int randomNum) {
        this.randomNum = randomNum;
    }
}
